package com.wy.framework.actions.login;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;

import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.wy.component.communication.HTTPClientUtils;
import com.wy.component.dataConvert.BeanUtil;
import com.wy.component.easemob.httpclient.apidemo.EasemobIMUsers;
import com.wy.component.properties.PropertiesUtil;
import com.wy.component.redis.RedisUtil;
import com.wy.framework.actions.AbstractBaseAction;
import com.wy.framework.constants.Constants;
import com.wy.framework.constants.RtnCodeConstant;
import com.wy.framework.dao.ErrorSqlException;
import com.wy.framework.exceptions.ServiceException;
import com.wy.framework.pojos.TSysConfig;
import com.wy.framework.pojos.TSysUserinfo;
import com.wy.framework.services.login.LoginService;

/**
 * 项目名称：openportal
 * 类名称：LoginAction
 * 类描述：登录信息管理
 * 创建人：张旭星
 * 创建时间：2015-12-28 下午7:36:22
 * 修改人：张旭星
 * 修改时间：2015-12-28 下午7:36:22
 * 版本信息：@version 1.0
 * Copyright (c) 2015万雍科技（上海）有限公司-版权所有  
 * 修改备注：
 * @version 
 */
@ParentPackage("json")
@Namespace(value="/")
@SuppressWarnings({"rawtypes","unused"})
public class LoginAction extends AbstractBaseAction {
	
	private static final long serialVersionUID = -2524826759684025380L;

	private static Logger logger = LoggerFactory.getLogger(LoginAction.class);

	@Autowired
	private LoginService loginService;
	private TSysUserinfo userInfo;
	
	private List<Map> userMap;
	
	PropertiesUtil p = new PropertiesUtil();
	
	String token;
	
	/**
	 * 验证码
	 */
	private String verCode;
	private String current;
	private List list;
	private Map map;
	private List<Map> rows;
	private String menuData;

	@Action(value = "login", 
			results = { @Result(name = "success", type = "json", params = {
					"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
					"false"}) })
	public String login(){
		try {
			//测试批量注册环信
//			List<TSysUserinfo> list = (List<TSysUserinfo>) loginService.getDataBaseDao().getHibernateTemplate().find(" from TSysUserinfo ");
//	        for(TSysUserinfo tSysUserinfo : list){
//	        	ObjectNode datanode = JsonNodeFactory.instance.objectNode();
//	        	datanode.put("username",tSysUserinfo.getUserId());
//	        	datanode.put("nickname",tSysUserinfo.getUserName());
//	        	datanode.put("password", Constants.DEFAULT_PASSWORD);
//	        	ObjectNode createNewIMUserSingleNode = EasemobIMUsers.createNewIMUserSingle(datanode);
//	        	if (null != createNewIMUserSingleNode) {
//	        		System.out.println("注册IM用户[单个]: " + createNewIMUserSingleNode.toString());
//	        	}
//	        }
			
			//测试全删企业号人员和部门
//			JSONArray a = JSONArray.fromObject("[{\"userid\":\"101\",\"name\":\"周志康\",\"department\":[2630]},{\"userid\":\"102\",\"name\":\"杜伟峰\",\"department\":[2630]},{\"userid\":\"103\",\"name\":\"花克勤\",\"department\":[2625]},{\"userid\":\"105\",\"name\":\"夏佳\",\"department\":[2610]},{\"userid\":\"106\",\"name\":\"张磉\",\"department\":[2617]},{\"userid\":\"108\",\"name\":\"周燕\",\"department\":[2615]},{\"userid\":\"11\",\"name\":\"何敏\",\"department\":[2628]},{\"userid\":\"110\",\"name\":\"王冬妹\",\"department\":[2615]},{\"userid\":\"111\",\"name\":\"陈萍\",\"department\":[2615]},{\"userid\":\"112\",\"name\":\"丁仁娟\",\"department\":[2615]},{\"userid\":\"113\",\"name\":\"杨丽君\",\"department\":[2615]},{\"userid\":\"114\",\"name\":\"蔡海华\",\"department\":[2615]},{\"userid\":\"118\",\"name\":\"罗文钊\",\"department\":[2615]},{\"userid\":\"119\",\"name\":\"杨云英\",\"department\":[2615]},{\"userid\":\"12\",\"name\":\"高嘉庆\",\"department\":[2628]},{\"userid\":\"121\",\"name\":\"严丹芬\",\"department\":[2621]},{\"userid\":\"125\",\"name\":\"鲍海俊\",\"department\":[2623]},{\"userid\":\"126\",\"name\":\"金春翔\",\"department\":[2623]},{\"userid\":\"127\",\"name\":\"陈诚\",\"department\":[2623]},{\"userid\":\"13\",\"name\":\"葛春晖\",\"department\":[2628]},{\"userid\":\"131\",\"name\":\"谢丽彬\",\"department\":[2623]},{\"userid\":\"132\",\"name\":\"李冠群\",\"department\":[2623]},{\"userid\":\"133\",\"name\":\"曾玲\",\"department\":[2623]},{\"userid\":\"137\",\"name\":\"窦春霞\",\"department\":[2623]},{\"userid\":\"139\",\"name\":\"徐钟\",\"department\":[2623]},{\"userid\":\"140\",\"name\":\"李金华\",\"department\":[2623]},{\"userid\":\"141\",\"name\":\"李晓琳\",\"department\":[2623]},{\"userid\":\"143\",\"name\":\"牛园园\",\"department\":[2623]},{\"userid\":\"145\",\"name\":\"申洪波\",\"department\":[2623]},{\"userid\":\"149\",\"name\":\"王欢\",\"department\":[2623]},{\"userid\":\"150\",\"name\":\"姚秀华\",\"department\":[2623]},{\"userid\":\"151\",\"name\":\"Noreen\",\"department\":[2623]},{\"userid\":\"152\",\"name\":\"陆效用\",\"department\":[2635]},{\"userid\":\"153\",\"name\":\"李爱群\",\"department\":[2635]},{\"userid\":\"156\",\"name\":\"花莹\",\"department\":[2635]},{\"userid\":\"157\",\"name\":\"叶梅\",\"department\":[2635]},{\"userid\":\"158\",\"name\":\"刘美丽\",\"department\":[2635]},{\"userid\":\"160\",\"name\":\"宋君\",\"department\":[2635]},{\"userid\":\"161\",\"name\":\"严华\",\"department\":[2635]},{\"userid\":\"162\",\"name\":\"顾君\",\"department\":[2635]},{\"userid\":\"163\",\"name\":\"纪澍\",\"department\":[2635]},{\"userid\":\"164\",\"name\":\"程慧\",\"department\":[2635]},{\"userid\":\"165\",\"name\":\"施琴\",\"department\":[2635]},{\"userid\":\"166\",\"name\":\"张晶晶\",\"department\":[2635]},{\"userid\":\"167\",\"name\":\"陈洁华\",\"department\":[2635]},{\"userid\":\"17\",\"name\":\"田敏\",\"department\":[2628]},{\"userid\":\"171\",\"name\":\"吕旻\",\"department\":[2635]},{\"userid\":\"172\",\"name\":\"刘黎英\",\"department\":[2635]},{\"userid\":\"173\",\"name\":\"张妍一\",\"department\":[2635]},{\"userid\":\"174\",\"name\":\"张晓\",\"department\":[2635]},{\"userid\":\"175\",\"name\":\"郭勤\",\"department\":[2635]},{\"userid\":\"176\",\"name\":\"黎妮\",\"department\":[2635]},{\"userid\":\"177\",\"name\":\"丁晓惠\",\"department\":[2635]},{\"userid\":\"178\",\"name\":\"刘婧\",\"department\":[2635]},{\"userid\":\"179\",\"name\":\"朱丽\",\"department\":[2635]},{\"userid\":\"18\",\"name\":\"傅敏娜\",\"department\":[2628]},{\"userid\":\"180\",\"name\":\"郑筱筠\",\"department\":[2635]},{\"userid\":\"181\",\"name\":\"苏鸿全\",\"department\":[2635]},{\"userid\":\"182\",\"name\":\"胡帆\",\"department\":[2635]},{\"userid\":\"183\",\"name\":\"王晓珏\",\"department\":[2635]},{\"userid\":\"184\",\"name\":\"张明明\",\"department\":[2612]},{\"userid\":\"185\",\"name\":\"仇宝华\",\"department\":[2612]},{\"userid\":\"186\",\"name\":\"曹鑫海\",\"department\":[2621]},{\"userid\":\"187\",\"name\":\"宣宇\",\"department\":[2612]},{\"userid\":\"188\",\"name\":\"黄琦\",\"department\":[2612]},{\"userid\":\"189\",\"name\":\"龚莉莉\",\"department\":[2612]},{\"userid\":\"191\",\"name\":\"朴金梅\",\"department\":[2612]},{\"userid\":\"192\",\"name\":\"崔京花\",\"department\":[2612]},{\"userid\":\"194\",\"name\":\"李喆\",\"department\":[2612]},{\"userid\":\"195\",\"name\":\"朱莉\",\"department\":[2612]},{\"userid\":\"197\",\"name\":\"靳君\",\"department\":[2612]},{\"userid\":\"198\",\"name\":\"董琰\",\"department\":[2612]},{\"userid\":\"199\",\"name\":\"沈小芳\",\"department\":[2613]},{\"userid\":\"20\",\"name\":\"林君\",\"department\":[2629]},{\"userid\":\"200\",\"name\":\"夏会丽\",\"department\":[2612]},{\"userid\":\"204\",\"name\":\"金东勋\",\"department\":[2604]},{\"userid\":\"205\",\"name\":\"肖超\",\"department\":[2623]},{\"userid\":\"206\",\"name\":\"韩贞淑\",\"department\":[2604]},{\"userid\":\"207\",\"name\":\"靳蕾\",\"department\":[2604]},{\"userid\":\"208\",\"name\":\"严春英\",\"department\":[2604]},{\"userid\":\"21\",\"name\":\"陈蓉萍\",\"department\":[2629]},{\"userid\":\"210\",\"name\":\"吴善子\",\"department\":[2604]},{\"userid\":\"211\",\"name\":\"朴春实\",\"department\":[2604]},{\"userid\":\"212\",\"name\":\"李英顺\",\"department\":[2604]},{\"userid\":\"213\",\"name\":\"罗玲萍\",\"department\":[2604]},{\"userid\":\"214\",\"name\":\"金钟太\",\"department\":[2604]},{\"userid\":\"215\",\"name\":\"毕盛楠\",\"department\":[2604]},{\"userid\":\"216\",\"name\":\"甘露\",\"department\":[2617]},{\"userid\":\"217\",\"name\":\"王雪\",\"department\":[2604]},{\"userid\":\"219\",\"name\":\"孙文莉\",\"department\":[2638]},{\"userid\":\"220\",\"name\":\"黄慧华\",\"department\":[2638]},{\"userid\":\"221\",\"name\":\"孙佩君\",\"department\":[2638]},{\"userid\":\"222\",\"name\":\"李丹\",\"department\":[2638]},{\"userid\":\"223\",\"name\":\"黄琳\",\"department\":[2638]},{\"userid\":\"224\",\"name\":\"徐侃\",\"department\":[2638]},{\"userid\":\"226\",\"name\":\"张辰\",\"department\":[2638]},{\"userid\":\"231\",\"name\":\"唐池珍\",\"department\":[2637]},{\"userid\":\"233\",\"name\":\"赵燕平\",\"department\":[2638]},{\"userid\":\"234\",\"name\":\"陈凯先\",\"department\":[2618]},{\"userid\":\"237\",\"name\":\"聂雪莲\",\"department\":[2618]},{\"userid\":\"238\",\"name\":\"李升\",\"department\":[2618]},{\"userid\":\"241\",\"name\":\"杨萍\",\"department\":[2618]},{\"userid\":\"242\",\"name\":\"徐华\",\"department\":[2624]},{\"userid\":\"243\",\"name\":\"范颖\",\"department\":[2623]},{\"userid\":\"244\",\"name\":\"张燕\",\"department\":[2618]},{\"userid\":\"246\",\"name\":\"陈瑜\",\"department\":[2617]},{\"userid\":\"247\",\"name\":\"王燕涛\",\"department\":[2637]},{\"userid\":\"248\",\"name\":\"严婷婷\",\"department\":[2637]},{\"userid\":\"249\",\"name\":\"唐好好\",\"department\":[2637]},{\"userid\":\"250\",\"name\":\"孙競斐\",\"department\":[2637]},{\"userid\":\"252\",\"name\":\"徐晓葭\",\"department\":[2637]},{\"userid\":\"257\",\"name\":\"王铮\",\"department\":[2637]},{\"userid\":\"26\",\"name\":\"段仁启\",\"department\":[2628]},{\"userid\":\"260\",\"name\":\"刘丽\",\"department\":[2613]},{\"userid\":\"261\",\"name\":\"杨春兰\",\"department\":[2613]},{\"userid\":\"263\",\"name\":\"邹娟\",\"department\":[2613]},{\"userid\":\"265\",\"name\":\"罗闽\",\"department\":[2613]},{\"userid\":\"268\",\"name\":\"周琼琼\",\"department\":[2613]},{\"userid\":\"269\",\"name\":\"谢纪璇\",\"department\":[2613]},{\"userid\":\"27\",\"name\":\"汤丽佳\",\"department\":[2611]},{\"userid\":\"271\",\"name\":\"刘艳\",\"department\":[2613]},{\"userid\":\"277\",\"name\":\"贝佳毅\",\"department\":[2613]},{\"userid\":\"28\",\"name\":\"姚渊\",\"department\":[2611]},{\"userid\":\"281\",\"name\":\"张石伟\",\"department\":[2613]},{\"userid\":\"285\",\"name\":\"赵威\",\"department\":[2619]},{\"userid\":\"288\",\"name\":\"刘向阳\",\"department\":[2619]},{\"userid\":\"289\",\"name\":\"郁莉莉\",\"department\":[2606]},{\"userid\":\"29\",\"name\":\"乔旭华\",\"department\":[2611]},{\"userid\":\"290\",\"name\":\"王宇翔\",\"department\":[2606]},{\"userid\":\"291\",\"name\":\"魏征\",\"department\":[2606]},{\"userid\":\"292\",\"name\":\"杨顺\",\"department\":[2606]},{\"userid\":\"294\",\"name\":\"邹满升\",\"department\":[2619]},{\"userid\":\"295\",\"name\":\"郑磊\",\"department\":[2619]},{\"userid\":\"296\",\"name\":\"韩萍\",\"department\":[2606]},{\"userid\":\"298\",\"name\":\"郑莎莉\",\"department\":[2619]},{\"userid\":\"300\",\"name\":\"吕晓冬\",\"department\":[2619]},{\"userid\":\"302\",\"name\":\"赵峰珂\",\"department\":[2619]},{\"userid\":\"303\",\"name\":\"杨阳\",\"department\":[2619]},{\"userid\":\"304\",\"name\":\"陈静静\",\"department\":[2619]},{\"userid\":\"306\",\"name\":\"郑舒文\",\"department\":[2619]},{\"userid\":\"308\",\"name\":\"陈海静\",\"department\":[2619]},{\"userid\":\"309\",\"name\":\"陈蔚文\",\"department\":[2606]},{\"userid\":\"31\",\"name\":\"张磊\",\"department\":[2610]},{\"userid\":\"310\",\"name\":\"梁三立\",\"department\":[2606]},{\"userid\":\"311\",\"name\":\"张德平\",\"department\":[2606]},{\"userid\":\"312\",\"name\":\"李楠\",\"department\":[2606]},{\"userid\":\"314\",\"name\":\"王魁鸿\",\"department\":[2606]},{\"userid\":\"316\",\"name\":\"李韬\",\"department\":[2606]},{\"userid\":\"317\",\"name\":\"贾金贵\",\"department\":[2606]},{\"userid\":\"318\",\"name\":\"张理\",\"department\":[2606]},{\"userid\":\"319\",\"name\":\"赵凌秀\",\"department\":[2606]},{\"userid\":\"32\",\"name\":\"王敏\",\"department\":[2610]},{\"userid\":\"320\",\"name\":\"方金华\",\"department\":[2606]},{\"userid\":\"321\",\"name\":\"吴卫奇\",\"department\":[2606]},{\"userid\":\"323\",\"name\":\"朱云\",\"department\":[2606]},{\"userid\":\"324\",\"name\":\"单静\",\"department\":[2606]},{\"userid\":\"325\",\"name\":\"陈小明\",\"department\":[2617]},{\"userid\":\"326\",\"name\":\"李兰英\",\"department\":[2617]},{\"userid\":\"3260\",\"name\":\"吴婷婷\",\"department\":[2623]},{\"userid\":\"3261\",\"name\":\"孟婕\",\"department\":[2637]},{\"userid\":\"3262\",\"name\":\"张连梅\",\"department\":[2607]},{\"userid\":\"3263\",\"name\":\"苗婉茹\",\"department\":[2617]},{\"userid\":\"3264\",\"name\":\"梁艳\",\"department\":[2612]},{\"userid\":\"3265\",\"name\":\"黄蓉\",\"department\":[2638]},{\"userid\":\"327\",\"name\":\"陈玲玲\",\"department\":[2617]},{\"userid\":\"329\",\"name\":\"张虹\",\"department\":[2617]},{\"userid\":\"33\",\"name\":\"瞿春燕\",\"department\":[2610]},{\"userid\":\"330\",\"name\":\"陈维扬\",\"department\":[2617]},{\"userid\":\"333\",\"name\":\"魏少华\",\"department\":[2617]},{\"userid\":\"334\",\"name\":\"纪如曼\",\"department\":[2617]},{\"userid\":\"335\",\"name\":\"薛丽丽\",\"department\":[2617]},{\"userid\":\"336\",\"name\":\"张唯\",\"department\":[2617]},{\"userid\":\"338\",\"name\":\"郭威\",\"department\":[2617]},{\"userid\":\"339\",\"name\":\"刘向朝\",\"department\":[2617]},{\"userid\":\"34\",\"name\":\"乔琼\",\"department\":[2607]},{\"userid\":\"340\",\"name\":\"杨剑宇\",\"department\":[2617]},{\"userid\":\"343\",\"name\":\"郑青\",\"department\":[2617]},{\"userid\":\"346\",\"name\":\"姚惠福\",\"department\":[2607]},{\"userid\":\"347\",\"name\":\"李志伟\",\"department\":[2607]},{\"userid\":\"348\",\"name\":\"马亮\",\"department\":[2607]},{\"userid\":\"349\",\"name\":\"胡晶\",\"department\":[2607]},{\"userid\":\"350\",\"name\":\"王震\",\"department\":[2607]},{\"userid\":\"351\",\"name\":\"刘彤\",\"department\":[2607]},{\"userid\":\"352\",\"name\":\"胡缨\",\"department\":[2607]},{\"userid\":\"353\",\"name\":\"陆履亨\",\"department\":[2607]},{\"userid\":\"356\",\"name\":\"卜兆\",\"department\":[2607]},{\"userid\":\"358\",\"name\":\"付立平\",\"department\":[2607]},{\"userid\":\"359\",\"name\":\"陈江媛\",\"department\":[2607]},{\"userid\":\"36\",\"name\":\"陈侃\",\"department\":[2610]},{\"userid\":\"360\",\"name\":\"鲍爱国\",\"department\":[2607]},{\"userid\":\"364\",\"name\":\"张冬梅\",\"department\":[2612]},{\"userid\":\"37\",\"name\":\"周忠鹏\",\"department\":[2610]},{\"userid\":\"38\",\"name\":\"刘南\",\"department\":[2610]},{\"userid\":\"39\",\"name\":\"顾文钧\",\"department\":[2625]},{\"userid\":\"40\",\"name\":\"冯锡刚\",\"department\":[2625]},{\"userid\":\"43\",\"name\":\"王芳\",\"department\":[2614]},{\"userid\":\"44\",\"name\":\"刘满珍\",\"department\":[2614]},{\"userid\":\"45\",\"name\":\"施群\",\"department\":[2614]},{\"userid\":\"46\",\"name\":\"周惠英\",\"department\":[2615]},{\"userid\":\"46396\",\"name\":\"王立进\",\"department\":[2613]},{\"userid\":\"46397\",\"name\":\"于丽艳\",\"department\":[2613]},{\"userid\":\"46398\",\"name\":\"董淼\",\"department\":[2613]},{\"userid\":\"46400\",\"name\":\"苗绿茵\",\"department\":[2613]},{\"userid\":\"46401\",\"name\":\"王芳\",\"department\":[2618]},{\"userid\":\"46403\",\"name\":\"傅建辉\",\"department\":[2610]},{\"userid\":\"46405\",\"name\":\"张志成\",\"department\":[2628]},{\"userid\":\"46407\",\"name\":\"徐光明\",\"department\":[2610]},{\"userid\":\"46408\",\"name\":\"高美华\",\"department\":[2617]},{\"userid\":\"46410\",\"name\":\"沈雅芳\",\"department\":[2622]},{\"userid\":\"46412\",\"name\":\"王松林\",\"department\":[2615]},{\"userid\":\"46414\",\"name\":\"王备呗\",\"department\":[2623]},{\"userid\":\"46416\",\"name\":\"王丹波\",\"department\":[2623]},{\"userid\":\"46417\",\"name\":\"王惠惠\",\"department\":[2623]},{\"userid\":\"46424\",\"name\":\"林之丹\",\"department\":[2635]},{\"userid\":\"46430\",\"name\":\"朱丽霞\",\"department\":[2613]},{\"userid\":\"46432\",\"name\":\"王正明\",\"department\":[2619]},{\"userid\":\"46433\",\"name\":\"罗莎莎\",\"department\":[2619]},{\"userid\":\"46435\",\"name\":\"金爱敏\",\"department\":[2606]},{\"userid\":\"46585\",\"name\":\"张佼\",\"department\":[2637]},{\"userid\":\"46603\",\"name\":\"王伟军\",\"department\":[2619]},{\"userid\":\"46608\",\"name\":\"韩文妍\",\"department\":[2618]},{\"userid\":\"46613\",\"name\":\"沈崇圣\",\"department\":[2607]},{\"userid\":\"46615\",\"name\":\"陈家林\",\"department\":[2607]},{\"userid\":\"46619\",\"name\":\"郑芳\",\"department\":[2612]},{\"userid\":\"46627\",\"name\":\"严巧英\",\"department\":[2635]},{\"userid\":\"46628\",\"name\":\"侯晓莉\",\"department\":[2623]},{\"userid\":\"46634\",\"name\":\"钟萌\",\"department\":[2617]},{\"userid\":\"46636\",\"name\":\"任占涛\",\"department\":[2617]},{\"userid\":\"46639\",\"name\":\"童争雄\",\"department\":[2606]},{\"userid\":\"46642\",\"name\":\"甘家宝\",\"department\":[2606]},{\"userid\":\"46643\",\"name\":\"甘龙飞\",\"department\":[2606]},{\"userid\":\"46644\",\"name\":\"张书台\",\"department\":[2606]},{\"userid\":\"46645\",\"name\":\"柳明池\",\"department\":[2606]},{\"userid\":\"46652\",\"name\":\"李滨滨\",\"department\":[2613]},{\"userid\":\"46654\",\"name\":\"林一平\",\"department\":[2606]},{\"userid\":\"46656\",\"name\":\"朱树德\",\"department\":[2606]},{\"userid\":\"46666\",\"name\":\"曲岩\",\"department\":[2617]},{\"userid\":\"46669\",\"name\":\"贺琼海\",\"department\":[2606]},{\"userid\":\"46672\",\"name\":\"沈丹凤\",\"department\":[2615]},{\"userid\":\"46673\",\"name\":\"孙萌\",\"department\":[2623]},{\"userid\":\"46675\",\"name\":\"仇晓芬\",\"department\":[2607]},{\"userid\":\"47\",\"name\":\"周燚君\",\"department\":[2614]},{\"userid\":\"47113\",\"name\":\"虞龙发\",\"department\":[2638]},{\"userid\":\"47115\",\"name\":\"马琳\",\"department\":[2619]},{\"userid\":\"47117\",\"name\":\"吴欣舫\",\"department\":[2618]},{\"userid\":\"47131\",\"name\":\"郑春英\",\"department\":[2629]},{\"userid\":\"47132\",\"name\":\"乔海萍\",\"department\":[2629]},{\"userid\":\"47137\",\"name\":\"戴佳丽\",\"department\":[2617]},{\"userid\":\"47138\",\"name\":\"马文婷\",\"department\":[2617]},{\"userid\":\"47140\",\"name\":\"王佳丽\",\"department\":[2606]},{\"userid\":\"47143\",\"name\":\"包晨\",\"department\":[2618]},{\"userid\":\"47144\",\"name\":\"尹瑞华\",\"department\":[2635]},{\"userid\":\"47145\",\"name\":\"蒋靖柯\",\"department\":[2619]},{\"userid\":\"47146\",\"name\":\"徐子寓\",\"department\":[2624]},{\"userid\":\"47154\",\"name\":\"徐菁菁\",\"department\":[2623]},{\"userid\":\"47155\",\"name\":\"夏洋洋\",\"department\":[2623]},{\"userid\":\"47157\",\"name\":\"袁明\",\"department\":[2606]},{\"userid\":\"47158\",\"name\":\"孙辉\",\"department\":[2623]},{\"userid\":\"47167\",\"name\":\"何启恒\",\"department\":[2631]},{\"userid\":\"47171\",\"name\":\"金子旸\",\"department\":[2613]},{\"userid\":\"47174\",\"name\":\"孙燕\",\"department\":[2618]},{\"userid\":\"47175\",\"name\":\"王建军\",\"department\":[2604]},{\"userid\":\"47176\",\"name\":\"钟松影\",\"department\":[2613]},{\"userid\":\"47179\",\"name\":\"周虹\",\"department\":[2613]},{\"userid\":\"47188\",\"name\":\"王列汇\",\"department\":[2623]},{\"userid\":\"47189\",\"name\":\"桂玲\",\"department\":[2623]},{\"userid\":\"47190\",\"name\":\"王少丽\",\"department\":[2613]},{\"userid\":\"47192\",\"name\":\"李飞\",\"department\":[2606]},{\"userid\":\"47193\",\"name\":\"林慧\",\"department\":[2613]},{\"userid\":\"47194\",\"name\":\"倪秋思\",\"department\":[2628]},{\"userid\":\"47195\",\"name\":\"尤东旭\",\"department\":[2612]},{\"userid\":\"47196\",\"name\":\"郑荣松\",\"department\":[2606]},{\"userid\":\"47197\",\"name\":\"夏利群\",\"department\":[2638]},{\"userid\":\"47198\",\"name\":\"马长龙\",\"department\":[2637]},{\"userid\":\"48\",\"name\":\"赵婷\",\"department\":[2614]},{\"userid\":\"49\",\"name\":\"张玲\",\"department\":[2614]},{\"userid\":\"50\",\"name\":\"陈东\",\"department\":[2614]},{\"userid\":\"50391\",\"name\":\"孙丰怡\",\"department\":[2637]},{\"userid\":\"50392\",\"name\":\"崔耘\",\"department\":[2637]},{\"userid\":\"50393\",\"name\":\"付童\",\"department\":[2618]},{\"userid\":\"50395\",\"name\":\"胡颖\",\"department\":[2606]},{\"userid\":\"50398\",\"name\":\"沈政辉\",\"department\":[2631]},{\"userid\":\"50399\",\"name\":\"鲍杨艺\",\"department\":[2619]},{\"userid\":\"50408\",\"name\":\"郑玲\",\"department\":[2606]},{\"userid\":\"50409\",\"name\":\"吴楠楠\",\"department\":[2635]},{\"userid\":\"50414\",\"name\":\"陶敏\",\"department\":[2635]},{\"userid\":\"50419\",\"name\":\"苏冰洁\",\"department\":[2619]},{\"userid\":\"50423\",\"name\":\"李斌\",\"department\":[2606]},{\"userid\":\"50425\",\"name\":\"周辉\",\"department\":[2606]},{\"userid\":\"50427\",\"name\":\"杨海燕\",\"department\":[2604]},{\"userid\":\"50430\",\"name\":\"李嘉\",\"department\":[2606]},{\"userid\":\"50431\",\"name\":\"秦敏\",\"department\":[2606]},{\"userid\":\"50433\",\"name\":\"尹静\",\"department\":[2606]},{\"userid\":\"50434\",\"name\":\"张家荣\",\"department\":[2606]},{\"userid\":\"50435\",\"name\":\"闫萍\",\"department\":[2606]},{\"userid\":\"50437\",\"name\":\"陆海红\",\"department\":[2615]},{\"userid\":\"50438\",\"name\":\"朱勇浩\",\"department\":[2614]},{\"userid\":\"50439\",\"name\":\"伍倩倩\",\"department\":[2623]},{\"userid\":\"50440\",\"name\":\"王丽\",\"department\":[2613]},{\"userid\":\"50449\",\"name\":\"潘东菁\",\"department\":[2628]},{\"userid\":\"50451\",\"name\":\"毛忠明\",\"department\":[2620]},{\"userid\":\"50453\",\"name\":\"常俊\",\"department\":[2619]},{\"userid\":\"50454\",\"name\":\"高丽华\",\"department\":[2619]},{\"userid\":\"50455\",\"name\":\"陆毅英\",\"department\":[2624]},{\"userid\":\"50457\",\"name\":\"严欣泉\",\"department\":[2623]},{\"userid\":\"50459\",\"name\":\"朱一音\",\"department\":[2635]},{\"userid\":\"50460\",\"name\":\"胡春丽\",\"department\":[2613]},{\"userid\":\"50461\",\"name\":\"周阳\",\"department\":[2613]},{\"userid\":\"50465\",\"name\":\"张曼\",\"department\":[2612]},{\"userid\":\"50467\",\"name\":\"徐天宏\",\"department\":[2613]},{\"userid\":\"50472\",\"name\":\"陈晓明\",\"department\":[2606]},{\"userid\":\"50474\",\"name\":\"王丹\",\"department\":[2617]},{\"userid\":\"50475\",\"name\":\"Tenpao Lee\",\"department\":[2613]},{\"userid\":\"50476\",\"name\":\"王美云\",\"department\":[2617]},{\"userid\":\"50477\",\"name\":\"王佩华\",\"department\":[2613]},{\"userid\":\"50478\",\"name\":\"庄芹\",\"department\":[2617]},{\"userid\":\"50479\",\"name\":\"倪晓萍\",\"department\":[2610]},{\"userid\":\"50480\",\"name\":\"王冬冬\",\"department\":[2614]},{\"userid\":\"50481\",\"name\":\"杨燕玲\",\"department\":[2638]},{\"userid\":\"50482\",\"name\":\"汪骏良\",\"department\":[2617]},{\"userid\":\"50483\",\"name\":\"王保士\",\"department\":[2627]},{\"userid\":\"50484\",\"name\":\"Melissa Ann\",\"department\":[2613]},{\"userid\":\"50485\",\"name\":\"Claire Roseamund\",\"department\":[2613]},{\"userid\":\"50486\",\"name\":\"李莹\",\"department\":[2627]},{\"userid\":\"50488\",\"name\":\"William Roger Angus\",\"department\":[2613]},{\"userid\":\"50489\",\"name\":\"褚芳华\",\"department\":[2629]},{\"userid\":\"50490\",\"name\":\"陈庆\",\"department\":[2614]},{\"userid\":\"50491\",\"name\":\"夏正标\",\"department\":[2638]},{\"userid\":\"50492\",\"name\":\"沈承祖\",\"department\":[2606]},{\"userid\":\"50493\",\"name\":\"史青峰\",\"department\":[2606]},{\"userid\":\"50494\",\"name\":\"张伟\",\"department\":[2606]},{\"userid\":\"50501\",\"name\":\"李亚萍\",\"department\":[2635]},{\"userid\":\"50502\",\"name\":\"丁慧敏\",\"department\":[2623]},{\"userid\":\"50504\",\"name\":\"李国平\",\"department\":[2635]},{\"userid\":\"50505\",\"name\":\"Paris\",\"department\":[2623]},{\"userid\":\"50506\",\"name\":\"陈素红\",\"department\":[2635]},{\"userid\":\"50508\",\"name\":\"和水英\",\"department\":[2619]},{\"userid\":\"50509\",\"name\":\"曹元秋\",\"department\":[2619]},{\"userid\":\"50513\",\"name\":\"张翔\",\"department\":[2618]},{\"userid\":\"50515\",\"name\":\"闵千叶\",\"department\":[2613]},{\"userid\":\"50516\",\"name\":\"李翔宇\",\"department\":[2627]},{\"userid\":\"50517\",\"name\":\"吕冬梅\",\"department\":[2613]},{\"userid\":\"50518\",\"name\":\"陈婧\",\"department\":[2613]},{\"userid\":\"50519\",\"name\":\"杨振亚\",\"department\":[2637]},{\"userid\":\"50521\",\"name\":\"姜海山\",\"department\":[2620]},{\"userid\":\"50522\",\"name\":\"王吉连\",\"department\":[2630]},{\"userid\":\"50524\",\"name\":\"陈畅菲\",\"department\":[2623]},{\"userid\":\"50525\",\"name\":\"潘庭\",\"department\":[2613]},{\"userid\":\"50527\",\"name\":\"许欣燕\",\"department\":[2623]},{\"userid\":\"50528\",\"name\":\"张晓昕\",\"department\":[2613]},{\"userid\":\"50529\",\"name\":\"Nathan\",\"department\":[2623]},{\"userid\":\"50530\",\"name\":\"Eston\",\"department\":[2623]},{\"userid\":\"50532\",\"name\":\"童欣婕\",\"department\":[2638]},{\"userid\":\"50533\",\"name\":\"沈海燕\",\"department\":[2605]},{\"userid\":\"50534\",\"name\":\"陈莹\",\"department\":[2623]},{\"userid\":\"50538\",\"name\":\"裘轶文\",\"department\":[2618]},{\"userid\":\"50539\",\"name\":\"黄寅熀\",\"department\":[2604]},{\"userid\":\"50541\",\"name\":\"王燕杰\",\"department\":[2635]},{\"userid\":\"51\",\"name\":\"苏学翠\",\"department\":[2614]},{\"userid\":\"52\",\"name\":\"周军\",\"department\":[2614]},{\"userid\":\"55\",\"name\":\"诸美红\",\"department\":[2613]},{\"userid\":\"56\",\"name\":\"奚建亭\",\"department\":[2614]},{\"userid\":\"58\",\"name\":\"韩光盛\",\"department\":[2614]},{\"userid\":\"59\",\"name\":\"徐欣\",\"department\":[2614]},{\"userid\":\"60009\",\"name\":\"过晓丹\",\"department\":[2607]},{\"userid\":\"61\",\"name\":\"沈李\",\"department\":[2621]},{\"userid\":\"62972\",\"name\":\"房京坤\",\"department\":[2613]},{\"userid\":\"62981\",\"name\":\"朱南勤\",\"department\":[2633]},{\"userid\":\"63002\",\"name\":\"IRENE LUISE\",\"department\":[2618]},{\"userid\":\"63003\",\"name\":\"周耀华\",\"department\":[2615]},{\"userid\":\"63006\",\"name\":\"孙惠意\",\"department\":[2629]},{\"userid\":\"63008\",\"name\":\"王玉\",\"department\":[2619]},{\"userid\":\"63010\",\"name\":\"丁宏明\",\"department\":[2623]},{\"userid\":\"63011\",\"name\":\"韩伟\",\"department\":[2623]},{\"userid\":\"63013\",\"name\":\"Hayley Ann\",\"department\":[2613]},{\"userid\":\"63015\",\"name\":\"朱晓君\",\"department\":[2631]},{\"userid\":\"63016\",\"name\":\"许兰玉\",\"department\":[2613]},{\"userid\":\"63020\",\"name\":\"BAK TONG, SRENG\",\"department\":[2637]},{\"userid\":\"63022\",\"name\":\"于斌\",\"department\":[2630]},{\"userid\":\"63023\",\"name\":\"谢宁宁\",\"department\":[2623]},{\"userid\":\"63024\",\"name\":\"吴雅\",\"department\":[2623]},{\"userid\":\"63028\",\"name\":\"Anssi Mikael Mattila\",\"department\":[2613]},{\"userid\":\"63030\",\"name\":\"王磊\",\"department\":[2638]},{\"userid\":\"63031\",\"name\":\"都载淑\",\"department\":[2604]},{\"userid\":\"63032\",\"name\":\"周凯歌\",\"department\":[2619]},{\"userid\":\"63033\",\"name\":\"濮明\",\"department\":[2623]},{\"userid\":\"63035\",\"name\":\"秦元海\",\"department\":[2607]},{\"userid\":\"63036\",\"name\":\"杨涛\",\"department\":[2607]},{\"userid\":\"63037\",\"name\":\"张庆桐\",\"department\":[2607]},{\"userid\":\"63043\",\"name\":\"赖良\",\"department\":[2635]},{\"userid\":\"63044\",\"name\":\"朱秀华\",\"department\":[2602]},{\"userid\":\"63046\",\"name\":\"刘晓燕\",\"department\":[2604]},{\"userid\":\"63047\",\"name\":\"童勤国\",\"department\":[2607]},{\"userid\":\"63048\",\"name\":\"李国珍\",\"department\":[2619]},{\"userid\":\"63049\",\"name\":\"胡梦哲\",\"department\":[2618]},{\"userid\":\"63050\",\"name\":\"王秋凤\",\"department\":[2628]},{\"userid\":\"63051\",\"name\":\"李娜\",\"department\":[2604]},{\"userid\":\"63052\",\"name\":\"sicfltest\",\"department\":[2617]},{\"userid\":\"64\",\"name\":\"薛正豪\",\"department\":[2621]},{\"userid\":\"65\",\"name\":\"王媛\",\"department\":[2612]},{\"userid\":\"66\",\"name\":\"许艳\",\"department\":[2616]},{\"userid\":\"68\",\"name\":\"武桂玲\",\"department\":[2624]},{\"userid\":\"70\",\"name\":\"赵婷婷\",\"department\":[2624]},{\"userid\":\"71\",\"name\":\"储清\",\"department\":[2624]},{\"userid\":\"73\",\"name\":\"朱晓枫\",\"department\":[2631]},{\"userid\":\"74\",\"name\":\"胡叶芳\",\"department\":[2631]},{\"userid\":\"77\",\"name\":\"张永生\",\"department\":[2605]},{\"userid\":\"78\",\"name\":\"孙宪国\",\"department\":[2605]},{\"userid\":\"80\",\"name\":\"韩松\",\"department\":[2605]},{\"userid\":\"81\",\"name\":\"陈秀兰\",\"department\":[2605]},{\"userid\":\"82\",\"name\":\"洪钦茹\",\"department\":[2605]},{\"userid\":\"83\",\"name\":\"沈产模\",\"department\":[2605]},{\"userid\":\"84\",\"name\":\"王丹凤\",\"department\":[2622]},{\"userid\":\"85\",\"name\":\"杨军\",\"department\":[2622]},{\"userid\":\"87\",\"name\":\"李金宝\",\"department\":[2622]},{\"userid\":\"88\",\"name\":\"刘坤民\",\"department\":[2630]},{\"userid\":\"89\",\"name\":\"李华平\",\"department\":[2630]},{\"userid\":\"90\",\"name\":\"虞龙富\",\"department\":[2630]},{\"userid\":\"91\",\"name\":\"杨军\",\"department\":[2630]},{\"userid\":\"92\",\"name\":\"谢德才\",\"department\":[2630]},{\"userid\":\"93\",\"name\":\"叶祖福\",\"department\":[2630]},{\"userid\":\"94\",\"name\":\"熊旻\",\"department\":[2630]},{\"userid\":\"98\",\"name\":\"黄裕坤\",\"department\":[2630]},{\"userid\":\"a@a.com\",\"name\":\"万雍开发\",\"department\":[1]},{\"userid\":\"admin\",\"name\":\"系统管理员\",\"department\":[1]}]");
//			for(int i=0;i<a.size();i++){
//				JSONObject o = a.getJSONObject(i);
//				String userid = (String) o.get("userid");
//				System.out.println(HTTPClientUtils.sendGet("https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token=DLZ7IGvku6nvg99CvoRwPyylnBQrqk2IfRjEz4E4mA6IlpE3bgc3htKsAl_buPy9&userid="+userid));
//			}
//			for(int i=2600;i<2655;i++){
//				System.out.println(HTTPClientUtils.sendGet("https://qyapi.weixin.qq.com/cgi-bin/department/delete?access_token=DLZ7IGvku6nvg99CvoRwPyylnBQrqk2IfRjEz4E4mA6IlpE3bgc3htKsAl_buPy9&id="+i));
//			}
			
			//是否来自cas判断
			String casFlag = ServletActionContext.getRequest().getParameter("casFlag");
			rspCode = loginService.validate(userInfo,casFlag);
			if (rspCode.equals(RtnCodeConstant.RTN_CODE_SUCCESS)) {
				TSysUserinfo loginUser = loginService.getUserInfo(userInfo.getUserId());
				Set<String> actionSet = loginService.getUserAction(loginUser);
				loginUser.setActionSet(actionSet);
				token = UUID.randomUUID().toString();
				RedisUtil.setLoginUser(token, loginUser.getUserId());
				RedisUtil.setLoginUser(token+"-dept", loginUser.getDeptName());
				logger.info(" loginUser.getDeptName() : {}", loginUser.getDeptName());
				//得到用户菜单权限 返回给页面
				menuData = loginService.getMenuData(loginUser);
				return SUCCESS;
			}
		} catch (Exception e) {
			logger.info("系统异常:{}", e);
			rspCode = RtnCodeConstant.RTN_CODE_UNKNOW_ERROR;
		}
		return SUCCESS;
	}
	
	@Action(value = "logout", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
					"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
					"false"}) })
	public String logout(){
		try {
			RedisUtil.delLoginUser(ServletActionContext.getRequest().getParameter("token"));
			rspCode = RtnCodeConstant.RTN_CODE_SUCCESS;
		} catch (Exception e) {
			logger.info("系统异常:{}", e);
			rspCode = RtnCodeConstant.RTN_CODE_UNKNOW_ERROR;
		}
		return SUCCESS;
	}
	
	/**
	 * Function Name               appLogin                                   
	 * @return
	 * @throws ErrorSqlException          		             
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 * @description (APP登录)
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-2-3 下午9:14:36           张旭星                     Initial
	 **********************************************************************
	 */
	public String appLogin() throws ErrorSqlException, FileNotFoundException, IOException {
		String userId = ServletActionContext.getRequest().getParameter("userId");
		String password = ServletActionContext.getRequest().getParameter("password");
		String deviceType = ServletActionContext.getRequest().getParameter("deviceType");
		TSysUserinfo tSysUserinfo = new TSysUserinfo();
		tSysUserinfo.setUserId(userId);
		tSysUserinfo.setUserPassword(password);
		try {
			rspCode = loginService.validate(tSysUserinfo,null);
			if (rspCode.equals(RtnCodeConstant.RTN_CODE_SUCCESS)) {
				TSysUserinfo loginUser = loginService.getUserInfo(userId);
				//存储redis,token_userAccount_type_projectName
				String token = UUID.randomUUID().toString();
				RedisUtil.setLoginUser(token, userId);
				rows = new ArrayList();
				Map m = BeanUtil.convertBean(loginUser);
				m.put("token", token);
				TSysConfig tSysConfig = (TSysConfig) loginService.getDataBaseDao().load(TSysConfig.class, "AndroidVersion");
				m.put("AndroidVersion", tSysConfig.getConfigValue());
				rows.add(m);
				
				List<Map> list=loginService.getDataBaseDao().queryForList("t_sys_userinfo.queryUserInfoByUserId", userId);
				rows.addAll(list);
				List permissions = loginService.getDataBaseDao().queryForList("t_sys_userinfo.queryUserPermissioByUserId", userId);
				Map m1 = new HashMap();
				m1.put("permission", permissions);
				rows.add(m1);
			}
		} catch (Exception e) {
			logger.info("系统异常:{}", e);
			rspCode = RtnCodeConstant.RTN_CODE_UNKNOW_ERROR;
		}
		return SUCCESS;
	}
	
	/**
	 * Function Name               appLogout                                   
	 * @return
	 * @throws ErrorSqlException
	 * @throws FileNotFoundException
	 * @throws IOException          		             
	 * @description 登出
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-16 下午5:43:06           张旭星                     Initial
	 **********************************************************************
	 */
	public String appLogout() throws ErrorSqlException, FileNotFoundException, IOException {
		String token = ServletActionContext.getRequest().getParameter("token");
		try {
			RedisUtil.delLoginUser(token);
		} catch (Exception e) {
			logger.info("系统异常:{}", e);
			rspCode = RtnCodeConstant.RTN_CODE_UNKNOW_ERROR;
		}
		return SUCCESS;
	}
	
	//显示用户信息
	public String showUserInfo() throws ServiceException, ErrorSqlException{
		TSysUserinfo loginUser;
		String userAccount=ServletActionContext.getRequest().getParameter("userAccount");
		loginUser = loginService.getUserInfo(userAccount);
		userInfo = loginUser;
		return SUCCESS;
	}
	
	public String getCurrentRoot() throws DataAccessException, ErrorSqlException {
		String orgCode=ServletActionContext.getRequest().getParameter("orgCode");
		String userAccount=ServletActionContext.getRequest().getParameter("userAccount");
		current=loginService.getCurrentRoot(orgCode, userAccount);
		return SUCCESS;
	}
	
	public String checkUserInfo() throws DataAccessException, ErrorSqlException{
		String mobile=ServletActionContext.getRequest().getParameter("mobile");
		list=loginService.checkUserInfo(mobile);
		return SUCCESS;
	}
	
	public String updateUserInfo() throws DataAccessException, ErrorSqlException {
		rspCode=loginService.updateUserInfo(userInfo);
		return SUCCESS;
	}
	
//	public String getWXUserLogin() throws DataAccessException, ErrorSqlException, FileNotFoundException, IOException {
//		String openId=ServletActionContext.getRequest().getParameter("openId");
//		userMap=loginService.getWXUserLogin(openId);
//		return SUCCESS;
//	}
	
	public String updateWXUserInfo() throws ErrorSqlException, ServiceException{
//		rspCode=loginService.updateWXUserInfo(userInfo);
		return SUCCESS;
	}
	
//	public String queryQrCodeForWxUser() throws Exception {
//		try {
//			String openId = ServletActionContext.getRequest()
//					.getParameter("openId");
//			list = loginService.queryQrCodeForWxUser(openId);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return SUCCESS;
//	}
	
//	public String queryWXUser()throws Exception{
//		String openId = ServletActionContext.getRequest().getParameter("openId");
//		list = loginService.queryWXUser(openId);
//		return SUCCESS;
//	}
	
	public String getCurrent() {
		return current;
	}

	public void setCurrent(String current) {
		this.current = current;
	}

	public void setUserInfo(TSysUserinfo userInfo) {
		this.userInfo = userInfo;
	}

	public TSysUserinfo getUserInfo() {
		return userInfo;
	}

	public void setVerCode(String verCode) {
		this.verCode = verCode;
	}

		
	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public List<Map> getRows() {
		return rows;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public List<Map> getUserMap() {
		return userMap;
	}

	public void setUserMap(List<Map> userMap) {
		this.userMap = userMap;
	}

	@Override
	public String getRspMsg() {
		if (rspMsg != null && rspMsg.length() > 0) {
			return rspMsg;
		}
		if (rspCode.equals("000000")) {
			return msgSourceAdapter.getMessage(this.getClass().getSimpleName());
		} else {
			return msgSourceAdapter.getMessage(rspCode);
		}
	}

	public String getMenuData() {
		return menuData;
	}

	public void setMenuData(String menuData) {
		this.menuData = menuData;
	}
	
	
}
